# -*- coding: utf-8 -*-


from PySide.QtGui import *
from PySide.QtCore import *
import sys

QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))

class MyQQBox(QToolBox):
    def __init__(self,parent=None):
        super(MyQQBox,self).__init__(parent)
        #ToolButton
        toolButton1_1=QToolButton()
        #文字
        toolButton1_1.setText(self.tr("朽木"))
        #图片
        toolButton1_1.setIcon(QIcon("img/tx1.jpg"))
        #图片大小
        toolButton1_1.setIconSize(QSize(100,100))
        #按下去后，恢复
        toolButton1_1.setAutoRaise(True)
        #文图格式
        toolButton1_1.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        #抽屉
        groupbox1=QGroupBox()
        vlayout1=QVBoxLayout(groupbox1)
        #vlayout1.setMargin(10)
        vlayout1.setContentsMargins(10,10,10,10)
        vlayout1.setSpacing(10)
        vlayout1.setAlignment(Qt.AlignLeft)
        vlayout1.addWidget(toolButton1_1)
        vlayout1.addStretch()

        toolButton2_1=QToolButton()
        toolButton2_1.setText(self.tr("牛人"))
        toolButton2_1.setIcon(QIcon("img/tx2.jpg"))
        toolButton2_1.setIconSize(QSize(100,100))
        toolButton2_1.setAutoRaise(True)
        toolButton2_1.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        groupbox2=QGroupBox()
        vlayout2=QVBoxLayout(groupbox2)
        vlayout2.setContentsMargins(10,10,10,10)
        #vlayout2.setSpacing(10)
        vlayout2.setAlignment(Qt.AlignLeft)
        vlayout2.addWidget(toolButton2_1)
        vlayout2.addStretch()


        self.addItem(groupbox1,self.tr("我的同事"))
        self.addItem(groupbox2,self.tr("黑名单"))

if __name__ =="__main__":
    app= QApplication(sys.argv)
    myQQBox=MyQQBox()
    myQQBox.show()
    sys.exit(app.exec_())